package com.tjn.enum_;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * 使用枚举来写季节的类
 * 第一种方法
 * 使用 enum 关键字实现枚举
 */
public class Enumeration03 {
    public static void main(String[] args) {
        System.out.println(Season02.SPRING
                     +"\n"+Season02.SUMMER
                     +"\n"+Season02.AUTUMN
                     +"\n"+Season02.WINTER);
    }
}

/*
规则：
1.使用enum代替class
2.public static final Season01 SPRING = new Season01("春天", "温暖");
    直接用SPRING("春天", "温暖")代替，常量名（实参列表）
3.如果有多个常量，用逗号隔开即可
4.如果使用enum来实现枚举，将定义的常量对象写在最前面
5.如果我们使用的是无参构造器，创建常量对象，则可以省略 ()
 */

enum Season02{
//    public static final Season01 SPRING = new Season01("春天", "温暖");
//    public static final Season01 SUMMER = new Season01("夏天", "炎热");
//    public static final Season01 AUTUMN = new Season01("秋天", "凉爽");
//    public static final Season01 WINTER = new Season01("冬天", "寒冷");
    SPRING("春天", "温暖"),SUMMER("夏天", "炎热"),
    AUTUMN("秋天", "凉爽"),WINTER("冬天", "寒冷"),
    //如果要再写一个无参的常量对象，（）可以省略
    HI;


    private String name;
    private String desc;

    Season02() {
    }

    private Season02(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    // toString()方法，输出对象时，会自动调用toString()方法，输出对象的属性值
    @Override
    public String toString() {
        return "Season02{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}